// @(#)func.cc
// Time-stamp: <2009-02-11 19:14:47 root>
// Copyright 2008 Julian Qian
// Author: root@localhost.localdomain
// Version: $Id: func.cc,v 0.0 2008/12/09 03:31:23 root Exp $
// Keywords: 

#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <strings.h>

#include "func.hh"

char*
itoa(int ui){
    static char ibuf[BUF_LEN];
    snprintf(ibuf, BUF_LEN, "%u",  ui);
    return ibuf;
}

char* IP(ip_t ip){
	struct in_addr ia;
	ia.s_addr = htonl(ip);
	return inet_ntoa(ia);
}


char* timestr(int ut){
    static char g_timestr[50];
    time_t tt = (time_t)ut;
    bzero(g_timestr, sizeof(g_timestr));
    strftime(g_timestr, sizeof(g_timestr), "%Y-%m-%d %H:%M:%S", localtime(&tt));
    return g_timestr;
}
